import { post, get } from './http';
import { BASEURL } from './http.js';
import {showLoading, hideLoading} from '@/utils/toast.js';

//用户部分
export const getUserInfoApi = data => get('/user/getUserInfo', data); // 获取用户信息
export const getPhoneIdCodeApi = data => get('/user/getPhoneIdCode', data); // 获取验证码
export const phoneLoginApi = data => post('/user/phoneLogin', data);	//手机登录
export const wxLoginApi = data => post('/user/wxLogin', data);	//微信登录
export const aliLoginApi = data => post('/user/aliLogin', data);	//支付宝登录
export const getRolesApi = data => get('/com/getRoles', data);//获取用户职业列表
export const getCityTreeApi = data => get('/com/getCityTree', data);//获取城市列表
export const getUserDetailApi = data => get('/user/getUserDetail', data);//用户资料
export const uploadUserInfoApi = data => post('/user/uploadUserInfo', data);//更新用户信息

//挖机部分
export const mainPageApi = data => get('/digger/main', data);//主页接口
export const diggerHistoryApi = data => get('/digger/diggerHistory', data);//搜索历史
export const getMainFilterApi = data => get('/digger/getMainFilter', data);//首页筛选项
export const getPageDiggerApi = data => post('/digger/getPageDigger', data);//分页查询挖机
export const diggerDetailApi = data => get('/digger/diggerDetail', data);//挖机详情
export const getTestReportApi = data => get('/digger/getTestReport', data);//查看挖机检测报告

//卖车信息采集
export const uploadSellDiggerApi = data => post('/digger/uploadSellDigger', data);//卖车信息采集
export const getInfoListApi = data => post('/digger/getInfoList', data);//卖家获取卖车咨询列表
export const myInfoDetailApi = data => get('/digger/myInfoDetail', data);//获取卖车咨询详情
export const updateSellDiggerApi = data => post('/digger/updateSellDigger', data);//修改我的卖车详情
export const deleteInfoApi = data => get('/digger/deleteInfo', data);//删除我的卖车咨询
export const getMyTestApi = data => post('/digger/getMyTest', data);//管家获取现场检测列表
export const updateDiggerApi = data => post('/digger/updateDigger', data);//管家确认设备信息并更新提交
export const getTestKVApi = data => get('/digger/getTestKV', data);//获取检测报告的字段和可选值
export const uploadTestResultApi = data => post('/digger/uploadTestResult', data);//管家提交挖机基本信息后填写检测报告并提交
//管家上传图片详情
export const uploadDiggerImgApi = data => post('/digger/uploadDiggerImg', data);//管家上传图片详情
export const confirmSellApi = data => get('/digger/confirmSell', data);//管家确认上架


//配件部分
export const getStoreDetailApi = data => get('/store/getStoreDetail', data);//我的店铺页
export const getLocationApi = data => post('/store/getLocation', data);//定位接口
export const saveStorePageApi = data => post('/store/saveStorePage', data);//卖家创建店铺
export const uploadComponentApi = data => post('/store/uploadComponent', data);//卖家上架配件
export const getStoreViewApi = data => post('/store/getStoreView', data); //店铺预览
export const compDetailPageApi = data => get('/store/compDetailPage', data);//配件详情页面
export const getCompInfoApi = data => get('/store/getCompInfo', data);//获得修改配件信息
export const updateComponentApi = data => post('/store/updateComponent', data);//更新修改配件信息
export const deleteCompApi = data => get('/store/deleteComp', data);//删除配件信息
export const compMainPageApi = data => get('/store/compMainPage', data);//配件售卖首页
export const getBrandsApi = data => get('/com/getBrands', data);//配件页品牌列表


//资料和会员
export const getMemberKindsApi = data => get('/com/getMemberKinds', data);//会员页面
export const payOrderApi = data => post('/pay/payOrder', data);//会员购买购买资料
export const getPayResultApi = data => get('/com/getPayResult', data);//获得支付结果
export const datumPageApi = data => get('/datum/datumPage', data);//获取资料类型列表和分页的资料列表
export const datumHistoryApi = data => get('/datum/datumHistory', data);//资料搜索记录接口
export const getPageDatumApi = data => post('/datum/getPageDatum', data);//资料搜索结果（分类结果）
export const getDatumDetailPageApi = data => get('/datum/datumDetailPage', data);//资料详情页
export const getCommPageApi = data => post('/datum/getCommPage', data);//用户点击资料详情页的查看全部评论
export const getHtmlDatumApi = data => get('/datum/getHtmlDatum', data);//浏览图文类型资料
export const getVideoDatumApi = data => post('/datum/getVideoDatum', data);//浏览视频类型资料
export const uploadDatumCommApi = data => post('/datum/uploadDatumComm', data);//对资料进行评论
export const getMyDatumPageApi = data => post('/datum/getMyDatumPage', data);//我的资料页
export const getDatumUrlApi = data => get('/datum/getDatumUrl', data);//查看资料接口
export const getVideoUrlApi = data => get('/datum/getVideoUrl', data);//视频资料
export const getHtmlContentApi = data => get('/datum/getHtmlContent', data);//图文资料


//维修部分
export const getTypeFilterApi = data => get('/repair/getTypeFilter', data);//获取维修下单页可选项值
export const addRepairPageApi = data => post('/repair/addRepairPage', data);//提交维修下单信息
export const getRepairListApi = data => post('/repair/getRepairList', data);//分页查询维修信息列表（接单者、下单者查询是同一个接口）
export const deleteRepairApi = data => get('/repair/deleteRepair', data);//撤销（删除）维修订单
export const getRepairDetailApi = data => get('/repair/getRepairDetail', data);//维修信息详情页
export const repairTakeOrderApi = data => get('/repair/takeOrder', data);//接单维修
export const repairFinishOrderApi = data => post('/repair/finishOrder', data);//接单者提交维修完成

//拖车部分
export const getMyTrailersApi = data => post('/trailer/getMyTrailers', data);//分页查询我的拖车列表
export const getTrailerFilterApi = data => get('/trailer/getTrailerFilter', data);//获取拖车信息编辑页选项值
export const uploadTrailerPageApi = data => post('/trailer/uploadTrailerPage', data);//添加拖车信息
export const getTrailerDetailApi = data => get('/trailer/getTrailerDetail', data);//获取拖车详情
export const updateTrailerPageApi = data => post('/trailer/updateTrailerPage', data);//更新拖车信息
export const deleteTrailereApi = data => get('/trailer/deleteTrailer', data);//删除拖车信息
export const getPageTrailerApi = data => post('/trailer/getPageTrailer', data);//拖车首页分页查询


//招聘部分
export const getMyRecruitsApi = data => post('/recruit/getMyRecruits', data);//我的招聘列表页
export const getPublishFilterApi = data => get('/recruit/getPublishFilter', data);//招聘信息填写页可选项
export const publishRecruitApi = data => post('/recruit/publishRecruit', data);//添加招聘信息
export const deleteRecruitApi = data => get('/recruit/deleteRecruit', data);//删除招聘信息
export const getRecruitFilterApi = data => get('/recruit/getRecruitFilter', data);//招聘首页筛选项
export const getPageRecruitApi = data => post('/recruit/getPageRecruit', data);//招聘首页（分页查询）
export const getRecruitDetailApi = data => get('/recruit/getRecruitDetail', data);//招聘详情
export const getRecruitInfoApi = data => get('/recruit/getRecruitInfo', data);//编辑的时候获得招聘信息
export const updateRecruitApi = data => post('/recruit/updateRecruit', data);//更新招聘信息

//公共部分
export const searchCityListApi = data => get('/com/searchCityList', data);//字母排序的城市
export const beHideMemApi = data => get('/com/beHideMem', data);//是否隐藏会员相关
export const getInitalCityApi = data => get('/com/getInitialCity', data);//按首字母分组城市列表

export const getPrivacyApi = data => get('/user/getPrivacy', data);//获取隐私协议
export const getStatementApi = data => get('/user/getStatement', data);//服务协议
export const getVersionApi = data => get('/com/getVersion', data);//更新版本


//测试接口
export const testApi = data => get('/index.php/api/index/index', data);




//上传图片
export const uploadImgApi = data => {
	showLoading();
	return new Promise((resolve, reject) => {		
		uni.uploadFile({
			url: BASEURL + '/com/uploadImg',
			filePath: data.file,
			name: 'file',
			formData: {
				id: data.id,
				userId: uni.getStorageSync('userId')
			},
			header: {				
				userId: uni.getStorageSync('userId')
			},
			success: res => {
				resolve(JSON.parse(res.data));
			},
			fail: err => {
				reject();
			},
			complete() {
				hideLoading();
			}
		})
	})
}

